package tec.encode;

import java.io.UnsupportedEncodingException;

public class ConvertUtil {
	public static byte[] toByte(char c) {
		return(toTwoByte(c));
	}
	
	public static byte[] toTwoByte(int c) {
		c = (c & 0x0000FFFF);
		byte[] bs = new byte[2];
		bs[0] = (byte) (c >> 8);
		bs[1] = (byte) (c & 0x00FF);
		return(bs);		
	}
	
	public static char encode(int c, String charset) throws UnsupportedEncodingException {
		  byte[] bs = toByte((char) c);
		  String s = new String(bs, charset);
		  return(s.toCharArray()[0]);
	}
}
